Skip to content

MON-4035: Add ThanosQuerierConfig to ClusterMonitoring API#2769

Open
danielmellado wants to merge 1 commit intoopenshift:masterfrom
danielmellado:mon_4035_add_thanos_querier_config
Open

MON-4035: Add ThanosQuerierConfig to ClusterMonitoring API#2769
danielmellado wants to merge 1 commit intoopenshift:masterfrom
danielmellado:mon_4035_add_thanos_querier_config

Conversation

@danielmellado
Copy link
Contributor

Migrate the thanos-querier configmap settings to a CRD field within
ClusterMonitoringSpec in config/v1alpha1. The new ThanosQuerierConfig
struct supports:

  • nodeSelector: pod scheduling to specific nodes
  • resources: compute resource requests and limits
  • tolerations: pod tolerations for scheduling
  • topologySpreadConstraints: pod distribution across topology domains

Also removes per-field positive-quantity CEL checks from
ContainerResource request/limit fields to stay within the Kubernetes
CRD CEL validation cost budget (StaticEstimatedCRDCostLimit) with
7 component configs at MaxItems=10.

Signed-off-by: Daniel Mellado dmellado@fedoraproject.org

@openshift-ci-robot
Copy link

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 17, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 17, 2026

@danielmellado: This pull request references MON-4035 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.22." or "openshift-4.22.", but it targets "openshift-5.0" instead.

Details

In response to this:

Migrate the thanos-querier configmap settings to a CRD field within
ClusterMonitoringSpec in config/v1alpha1. The new ThanosQuerierConfig
struct supports:

  • nodeSelector: pod scheduling to specific nodes
  • resources: compute resource requests and limits
  • tolerations: pod tolerations for scheduling
  • topologySpreadConstraints: pod distribution across topology domains

Also removes per-field positive-quantity CEL checks from
ContainerResource request/limit fields to stay within the Kubernetes
CRD CEL validation cost budget (StaticEstimatedCRDCostLimit) with
7 component configs at MaxItems=10.

Signed-off-by: Daniel Mellado dmellado@fedoraproject.org

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 17, 2026

Hello @danielmellado! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

A new optional thanosQuerierConfig field was added to ClusterMonitoringSpec (with minProperties=1) supporting nodeSelector, resources (named ContainerResource list, min 1/max 10, unique names, per-item request/limit rules), tolerations, and topologySpreadConstraints (min 1/max 10, unique key pairs). Validation requiring resource quantities to be >0 was removed from ContainerResource fields. Generated code and docs were updated (deepcopy and Swagger), the CRD schema was extended, and tests were added/modified to cover many thanosQuerierConfig acceptance and rejection cases and to remove some non-positive-quantity rejection tests.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.3)

Error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented
The command is terminated due to an error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 17, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 17, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml (1)

790-971: Add one explicit regression case for the relaxed quantity checks.

If the non-positive ContainerResource relaxation is intentional, please add one representative thanosQuerierConfig.resources create case for it. The new coverage only exercises list semantics and limit >= request, so that contract change is still implicit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml`
around lines 790 - 971, Add a regression test entry for the relaxed non-positive
ContainerResource check by inserting a new test case in the same YAML list that
validates thanosQuerierConfig.resources accepts a non-positive quantity (e.g.,
request: "0" and limit: "0"); the test should include a name like "Should be
able to create ThanosQuerierConfig with non-positive resources" and provide
identical initial and expected manifests under
spec.thanosQuerierConfig.resources to assert create succeeds with request "0"
and limit "0". Ensure the added case follows the same structure as existing
tests (name, initial, expected) and targets thanosQuerierConfig.resources so the
change in semantics is explicitly covered.
payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml (1)

4656-4702: Consider disallowing negative quantities in the regex to match the documented contract.

limit/request descriptions state values must be > 0, but the current pattern accepts a leading -. Tightening the regex keeps validation cheap while aligning behavior with docs.

Suggested diff
-                          pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+                          pattern: ^(\+)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
...
-                          pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+                          pattern: ^(\+)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml`
around lines 4656 - 4702, The regex for resource quantities in the limit and
request fields currently allows a leading '-' which contradicts the documented
"must be greater than 0" constraint; update the pattern in both the limit and
request definitions (the pattern under the limit and request properties) to
remove the optional negative sign (e.g., change ^(\+|-)?... to ^(\+)?... or
simply drop the sign group) so negative values are rejected while preserving the
rest of the quantity syntax and x-kubernetes-int-or-string behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml`:
- Around line 790-971: Add a regression test entry for the relaxed non-positive
ContainerResource check by inserting a new test case in the same YAML list that
validates thanosQuerierConfig.resources accepts a non-positive quantity (e.g.,
request: "0" and limit: "0"); the test should include a name like "Should be
able to create ThanosQuerierConfig with non-positive resources" and provide
identical initial and expected manifests under
spec.thanosQuerierConfig.resources to assert create succeeds with request "0"
and limit "0". Ensure the added case follows the same structure as existing
tests (name, initial, expected) and targets thanosQuerierConfig.resources so the
change in semantics is explicitly covered.

In
`@payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml`:
- Around line 4656-4702: The regex for resource quantities in the limit and
request fields currently allows a leading '-' which contradicts the documented
"must be greater than 0" constraint; update the pattern in both the limit and
request definitions (the pattern under the limit and request properties) to
remove the optional negative sign (e.g., change ^(\+|-)?... to ^(\+)?... or
simply drop the sign group) so negative values are rejected while preserving the
rest of the quantity syntax and x-kubernetes-int-or-string behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: af668436-5d4c-40ff-9589-2615607272cd

📥 Commits

Reviewing files that changed from the base of the PR and between 5c75e62 and 4f6fc30.

⛔ Files ignored due to path filters (4)
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml is excluded by !**/zz_generated.crd-manifests/*
  • config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • openapi/generated_openapi/zz_generated.openapi.go is excluded by !openapi/**
  • openapi/openapi.json is excluded by !openapi/**
📒 Files selected for processing (5)
  • config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml
  • config/v1alpha1/types_cluster_monitoring.go
  • config/v1alpha1/zz_generated.deepcopy.go
  • config/v1alpha1/zz_generated.swagger_doc_generated.go
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml

Copy link
Contributor

@yuqi-zhang yuqi-zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally lgtm, thanks for the clear documentation and tests. Just had some minor questions/comments inline + some nits/suggestions

Migrate the thanos-querier configmap settings to a CRD field within
ClusterMonitoringSpec in config/v1alpha1. The new ThanosQuerierConfig
struct supports:

- nodeSelector: pod scheduling to specific nodes
- resources: compute resource requests and limits
- tolerations: pod tolerations for scheduling
- topologySpreadConstraints: pod distribution across topology domains

Also removes per-field positive-quantity CEL checks from
ContainerResource request/limit fields to stay within the Kubernetes
CRD CEL validation cost budget (StaticEstimatedCRDCostLimit) with
7 component configs at MaxItems=10.

Signed-off-by: Daniel Mellado <dmellado@fedoraproject.org>
@danielmellado danielmellado force-pushed the mon_4035_add_thanos_querier_config branch from 4f6fc30 to 19ce37e Compare March 24, 2026 10:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/v1alpha1/types_cluster_monitoring.go`:
- Around line 771-781: Update the documentation examples in the comments for the
resources list to remove "limit: null" and instead omit the limit field (or show
it as unset) so the examples match the actual non-nullable schema; specifically
edit the comment blocks that list the default resources (the entries with "-
name: cpu" and "- name: memory") to drop "limit: null" for the resource items
referenced by the resources list in types_cluster_monitoring.go.

In
`@payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml`:
- Around line 4660-4693: thanosQuerierConfig.resources currently allows negative
quantities because the regex for limit and request includes an optional "-" and
no CEL validation enforces positivity; update the pattern for both the limit and
request fields to remove the optional negative sign (replace the leading
'(\+|-)?' with either '(\+)?' or no sign) and add an x-kubernetes-validations
CEL rule on thanosQuerierConfig.resources.request and .limit that asserts the
parsed quantity is positive (e.g., use a CEL expression that converts the value
to a Quantity/number and checks > 0) so negative values are rejected at CRD
validation time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 68e62516-6e4b-435c-99aa-4d235de5d96e

📥 Commits

Reviewing files that changed from the base of the PR and between 4f6fc30 and 19ce37e.

⛔ Files ignored due to path filters (4)
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml is excluded by !**/zz_generated.crd-manifests/*
  • config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • openapi/generated_openapi/zz_generated.openapi.go is excluded by !openapi/**
  • openapi/openapi.json is excluded by !openapi/**
📒 Files selected for processing (5)
  • config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml
  • config/v1alpha1/types_cluster_monitoring.go
  • config/v1alpha1/zz_generated.deepcopy.go
  • config/v1alpha1/zz_generated.swagger_doc_generated.go
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml
✅ Files skipped from review due to trivial changes (1)
  • config/v1alpha1/zz_generated.deepcopy.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml

Comment on lines 771 to +781
// The current default values are:
// resources:
// - name: cpu
// request: 4m
// limit: null
// - name: memory
// request: 40Mi
// limit: null
// Maximum length for this list is 10.
// Minimum length for this list is 1.
// Each resource name must be unique within this list.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

CRD="$(fd '0000_10_config-operator_01_clustermonitorings\.crd\.yaml$' | head -n1)"
if [[ -z "${CRD}" ]]; then
  echo "Could not find the generated ClusterMonitoring CRD." >&2
  exit 1
fi

python -m pip install --quiet pyyaml >/dev/null

python - "$CRD" <<'PY'
from pathlib import Path
import sys
import yaml

doc = yaml.safe_load(Path(sys.argv[1]).read_text())
versions = doc.get("spec", {}).get("versions", [])
schema = None
for version in versions:
    if version.get("name") == "v1alpha1":
        schema = version.get("schema", {}).get("openAPIV3Schema")
        break

if schema is None:
    raise SystemExit("v1alpha1 schema not found in generated CRD")

limit_nodes = []
description_hits = []

def walk(node, path):
    if isinstance(node, dict):
        if path and path[-1] == "limit" and node.get("x-kubernetes-int-or-string"):
            limit_nodes.append({
                "path": ".".join(path),
                "nullable": node.get("nullable"),
                "x-kubernetes-nullable": node.get("x-kubernetes-nullable"),
            })
        desc = node.get("description")
        if isinstance(desc, str) and "limit: null" in desc:
            description_hits.append({
                "path": ".".join(path),
                "lines": [
                    line for line in desc.splitlines()
                    if "resources:" in line or "request:" in line or "limit:" in line
                ],
            })
        for key, value in node.items():
            walk(value, path + [str(key)])
    elif isinstance(node, list):
        for index, value in enumerate(node):
            walk(value, path + [f"[{index}]"])

walk(schema, [])

print("limit schemas:")
for item in limit_nodes[:20]:
    print(item)

print("\ndescriptions containing 'limit: null':")
for item in description_hits[:20]:
    print(item["path"])
    for line in item["lines"]:
        print("  " + line)
    print()

print("nullable limit schemas found:", any(item["nullable"] or item["x-kubernetes-nullable"] for item in limit_nodes))
PY

Repository: openshift/api

Length of output: 2453


Remove limit: null from documentation examples.

The generated CRD schema does not mark limit fields as nullable across all resource configurations, yet the code comments show limit: null in examples. Either omit the limit field entirely or describe it as unset in the documentation to align with the actual API surface.

Diff to align the examples with the field shape
 // The current default values are:
 //   resources:
 //    - name: cpu
 //      request: 4m
-//      limit: null
 //    - name: memory
 //      request: 40Mi
-//      limit: null
 // Maximum length for this list is 10.
 // Minimum length for this list is 1.
 // Each resource name must be unique within this list.

This applies to multiple locations including lines 771-781 and 1771-1781.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// The current default values are:
// resources:
// - name: cpu
// request: 4m
// limit: null
// - name: memory
// request: 40Mi
// limit: null
// Maximum length for this list is 10.
// Minimum length for this list is 1.
// Each resource name must be unique within this list.
// The current default values are:
// resources:
// - name: cpu
// request: 4m
// - name: memory
// request: 40Mi
// Maximum length for this list is 10.
// Minimum length for this list is 1.
// Each resource name must be unique within this list.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/v1alpha1/types_cluster_monitoring.go` around lines 771 - 781, Update
the documentation examples in the comments for the resources list to remove
"limit: null" and instead omit the limit field (or show it as unset) so the
examples match the actual non-nullable schema; specifically edit the comment
blocks that list the default resources (the entries with "- name: cpu" and "-
name: memory") to drop "limit: null" for the resource items referenced by the
resources list in types_cluster_monitoring.go.

Comment on lines +4660 to +4693
description: |-
limit is the maximum amount of the resource allowed (e.g. "2Mi", "1Gi").
This field is optional.
When request is specified, limit cannot be less than request.
The value must be greater than 0 when specified.
maxLength: 20
minLength: 1
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
name:
description: |-
name of the resource (e.g. "cpu", "memory", "hugepages-2Mi").
This field is required.
name must consist only of alphanumeric characters, `-`, `_` and `.` and must start and end with an alphanumeric character.
maxLength: 253
minLength: 1
type: string
x-kubernetes-validations:
- message: name must consist only of alphanumeric characters,
`-`, `_` and `.` and must start and end with an alphanumeric
character
rule: '!format.qualifiedName().validate(self).hasValue()'
request:
anyOf:
- type: integer
- type: string
description: |-
request is the minimum amount of the resource required (e.g. "2Mi", "1Gi").
This field is optional.
When limit is specified, request cannot be greater than limit.
maxLength: 20
minLength: 1
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml"

echo "Inspecting thanosQuerierConfig.resources block (Line ~4652-4705):"
awk 'NR>=4652 && NR<=4705 {print NR ":" $0}' "$FILE"

echo
echo "Regex lines that allow optional minus sign:"
rg -n "^\s*pattern:\s*\^\(\\\+\|-\)\?" "$FILE"

echo
echo "Searching for explicit positive/non-negative CEL checks in this local block:"
awk 'NR>=4652 && NR<=4705 {print NR ":" $0}' "$FILE" | rg -n "isGreaterThan|quantity\\('0'\\)|>= 0" || true

Repository: openshift/api

Length of output: 3619


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml"

# Check if the quantityComparison and CEL rules in the resource block enforce positivity
echo "=== Full x-kubernetes-validations block for this resource item ==="
awk 'NR>=4697 && NR<=4705 {print NR ":" $0}' "$FILE"

echo
echo "=== Checking if pattern allows negative quantities ==="
# Extract just the pattern line to see it clearly
awk 'NR==4667 || NR==4692' "$FILE" | sed 's/^/  /'

echo
echo "=== Looking for other resource definitions with similar patterns ==="
rg -n "pattern.*\(\\\+\|-\)\?.*\^" "$FILE" | head -20

Repository: openshift/api

Length of output: 1127


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml"

echo "=== Analyzing the CEL rule at line 4701-4702 ==="
echo "The CEL rule only checks: quantity(limit).compareTo(quantity(request)) >= 0"
echo "This enforces limit >= request, but does NOT enforce value > 0"
echo

echo "=== Testing regex pattern interpretation ==="
# Create a test pattern to show it accepts negative values
PATTERN='^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$'

echo "Current pattern allows these test cases:"
echo "-1Mi" | grep -E "$PATTERN" && echo "  ✓ '-1Mi' matches" || echo "  ✗ '-1Mi' does not match"
echo "-512m" | grep -E "$PATTERN" && echo "  ✓ '-512m' matches" || echo "  ✗ '-512m' does not match"
echo "1Gi" | grep -E "$PATTERN" && echo "  ✓ '1Gi' matches" || echo "  ✗ '1Gi' does not match"

echo
echo "=== Checking if there's any other validation preventing negative resource quantities ==="
awk 'NR>=4652 && NR<=4705 {print}' "$FILE" | grep -iE "greater|positive|zero|negative" || echo "No additional constraints found"

Repository: openshift/api

Length of output: 741


thanosQuerierConfig.resources currently admits negative quantities

Lines 4667 and 4692 use a quantity regex pattern that allows the minus sign via (\+|-)?, and the x-kubernetes-validations block (lines 4697–4702) does not enforce positivity. The existing CEL rules only check that at least one of request/limit is set and that limit ≥ request; they do not prevent both values from being negative (e.g., both could be -1Mi). This allows invalid resource values at the CRD level, deferring failure to later reconciliation.

Proposed schema hardening (disallow negative sign in request/limit patterns)
-                          pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+                          pattern: ^(\+)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$

Apply to both line 4667 (limit) and line 4692 (request).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml`
around lines 4660 - 4693, thanosQuerierConfig.resources currently allows
negative quantities because the regex for limit and request includes an optional
"-" and no CEL validation enforces positivity; update the pattern for both the
limit and request fields to remove the optional negative sign (replace the
leading '(\+|-)?' with either '(\+)?' or no sign) and add an
x-kubernetes-validations CEL rule on thanosQuerierConfig.resources.request and
.limit that asserts the parsed quantity is positive (e.g., use a CEL expression
that converts the value to a Quantity/number and checks > 0) so negative values
are rejected at CRD validation time.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 24, 2026

@danielmellado: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants